package br.ufpe.cin.rgms.util;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;

public class HibernateUtil {

	private static SessionFactory factory;
	private static AnnotationConfiguration conf;

	static {
		conf = new AnnotationConfiguration();
		
		addAnnotatedClasses();

		initiliazeProperties();

		factory = conf.configure().buildSessionFactory();
	}

	private static void initiliazeProperties() {

	}

	private static void addAnnotatedClasses() {
		conf.addAnnotatedClass(br.ufpe.cin.rgms.membro.modelo.Membro.class);
		conf.addAnnotatedClass(br.ufpe.cin.rgms.membro.modelo.Estudante.class);
		conf.addAnnotatedClass(br.ufpe.cin.rgms.publicacao.modelo.Publicacao.class);
		conf.addAnnotatedClass(br.ufpe.cin.rgms.publicacao.modelo.ArtigoConferencia.class);
		conf.addAnnotatedClass(br.ufpe.cin.rgms.publicacao.modelo.PublicacaoPosGraduacao.class);
		conf.addAnnotatedClass(br.ufpe.cin.rgms.publicacao.modelo.ArtigoPeriodico.class);
		// #if ($linhasPesquisa)
		conf.addAnnotatedClass(br.ufpe.cin.rgms.linha.modelo.Linha.class);
		// #end
	}

	public static Session getSession() {
		return factory.openSession();
	}

	public static void swapPersistence(String type) {

	}
}
